package cn.codergege.gradle.plugin

import org.gradle.api.Project
import java.io.File

/**
 * 包级函数
 */

/**
 * 转换项目名称
 */
fun convertProjectName(project: Project): String {
    return project.name.split("-").map {
        it.replaceFirst(it[0], it[0].toUpperCase())
    }.joinToString(separator = "")
}

fun generateSourceCode(parentDir: File,
                       packageDir: String,
                       sourceFileName: String,
                       sourceCode: String) {
    if(packageDir != "") File(parentDir, "$packageDir").mkdirs()
    File(parentDir, "$packageDir/$sourceFileName")
        .writeText(sourceCode)
}

// 生成 readme.md 文件
fun generateFile(fileName:String, content: String) {
    File(fileName).writeText(content)
}